package com.argsstack;

import java.util.HashMap;

public class Args {

    private HashMap<Object, Arg> args;

    public Args() {
        args = new HashMap<Object, Arg>();
    }

    public int Count() {
        return args.size();
    }

    public Arg get(Object arg) {
        return args.get(arg);
    }
    
    public boolean contains(Object arg){
        return args.get(arg)!=null;
    }

    public Args push(Object obj, Arg value) {
        args.put(obj, value);
        return this;
    }
    
    public Args setValue(Object key, Object value) {
        Arg arg=args.get(key);
        if(arg==null){
            arg=new Arg(value);
        }else{
            arg=args.get(key);
            arg.setValue(value);
        }

        return this;
    }

    Args Clone() {
        Args stack = new Args();
        HashMap<Object, Arg> newValues = new HashMap<Object, Arg>();
        newValues.putAll(args);
        stack.args = newValues;
        return stack;
    }
}
